import { pathToFileURL, fileURLToPath } from "url";
import path from "path";
const ROOT_PATH = process.cwd();
const APP_PATH = path.join(ROOT_PATH, "app");
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const globals = {
  __dirname,
  __filename,
  ROOT_PATH,
  APP_PATH,
  CONFIG_PATH: path.join(ROOT_PATH, "config"),
  EXTEND_PATH: path.join(APP_PATH, "extend"),
  PUBLIC_PATH: path.join(ROOT_PATH, "public"),
  MODULES_PATH: path.join(APP_PATH, "modules"),
  COMMON_PATH: path.join(APP_PATH, "common"),
  HELPER_PATH: path.join(APP_PATH, "helper"),
};

for (const [key, value] of Object.entries(globals)) {
  Object.defineProperty(global, key, {
    value,
    writable: false, // 禁止修改
    configurable: false, //  禁止删除或重新定义
    enumerable: true, //  可枚举（调试时可见）
  });
}
